const multer = require('multer');
const path = require("node:path");


const storage = multer.diskStorage({
    destination: (req, file, cb) => {
        if (file.fieldname === 'group_pic') {
            cb(null, './public/gpfp')
        } else if (file.fieldname === 'banner') {
            cb(null, './public/banner')
        }
    },
    filename: function (req, file, cb) {
        cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname));
    },
});

const updateGroup = multer({
    storage: storage
});

module.exports = updateGroup;